/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						 adv_actor_model.cpp

	$Header: /heroes4/adv_actor_model.cpp $

	$NoKeywords: $

 ************************************************************************/

// kill the 255+ character identifier warning.  Templates tend to exceed that easily.
#include "precompiled.h"
#pragma warning( disable: 4786 )

#include "adv_actor_model.h"

#include "actor_model_impl.h"
#include "actor_sequence_cache.h"

// Explicitly instantiate t_actor_model< t_adv_actor_model_definition >
// This will cause all member functions to be instantiated
#pragma warning( push )
#pragma warning( disable: 4660 )
template t_actor_model< t_adv_actor_model_definition >;
#pragma warning( pop )

// ------------------------------------------------------------------------------
// t_adv_actor_model members
// ------------------------------------------------------------------------------
t_actor_model_base::~t_actor_model_base()
{
}

// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
t_adv_actor_model::t_adv_actor_model( t_adv_actor_model const & other )
	:	t_actor_model< t_adv_actor_model_definition >( other )
{
}

// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
t_adv_actor_model::t_adv_actor_model( t_cached_ptr< t_definition > definition_ptr )
	:	t_actor_model< t_adv_actor_model_definition >( definition_ptr )
{
}

// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
t_adv_actor_model::~t_adv_actor_model()
{
}

// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
t_adv_actor_model & t_adv_actor_model::operator=( t_adv_actor_model const & other )
{
	t_actor_model< t_adv_actor_model_definition >::operator=( other );
	return *this;
}

// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
t_map_point_2d t_adv_actor_model::get_size() const
{
	int size = get_footprint_size();
	return t_map_point_2d( size, size );
}

// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
bool t_adv_actor_model::are_any_cells_flat() const
{
	return false;
}

// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
bool t_adv_actor_model::are_any_cells_impassable() const
{
	return false;
}

// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
bool t_adv_actor_model::is_cell_flat( t_map_point_2d const & point ) const
{
	return false;
}

// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
bool t_adv_actor_model::is_cell_impassable( t_map_point_2d const & point ) const
{
	return false;
}

// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
bool t_adv_actor_model::is_left_edge_trigger( t_map_point_2d const & point ) const
{
	return point.column == 0 || point.column == get_footprint_size();
}

// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
bool t_adv_actor_model::is_right_edge_trigger( t_map_point_2d const & point ) const
{
	return point.row == 0 || point.row == get_footprint_size();
}

// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
bool t_adv_actor_model::is_trigger_cell( t_map_point_2d const& point ) const
{
	return true;
}

// ------------------------------------------------------------------------------
// get a sequence by name
// ------------------------------------------------------------------------------
t_actor_sequence_cache t_adv_actor_model::get_cache( std::string const&	 name,
										             t_screen_point const& offset ) const
{
	return get_actor_sequence_cache( name, offset );
}

// ------------------------------------------------------------------------------
// get a sequence by id
// ------------------------------------------------------------------------------
t_actor_sequence_ptr t_adv_actor_model::get_sequence_ptr( t_action_id action_id, 
										                  t_direction direction ) const
{
	assert( action_id >= 0 && action_id < k_action_count );
	assert( direction >= 0 && direction < k_direction_count );

	t_sequence_info & sequence_info = m_sequence_info_array_array[ action_id ][ direction ];

	if ( !sequence_info.loaded )
	{
		sequence_info.ptr = get_sequence_cache( action_id, direction ).get();
		sequence_info.loaded = true;
	}
	return sequence_info.ptr;
}
